package org.theqcp.wow.sim.gui.tabs;

import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.JPanel;
import javax.swing.GroupLayout.SequentialGroup;

import org.theqcp.wow.sim.gui.DataPoint;
import org.theqcp.wow.sim.gui.EnhSimGUIFrame;

public class Simulation extends DataPanel {

    private static final long serialVersionUID = 902109620969838811L;

    protected final String[] bossStats = new String[] { "Miss", "Dodge", "Glancing", "Armor", "Spell miss",
	    "Nature resist", "Fire resist", "Frost resist", "Arcane resist", "Shadow resist" };
    protected final String[] simulationStats = new String[] { "Sim time (hours)", "Combat log (minutes)",
	    "Combat length (minutes)", "Report count", "Threads", "Min lag", "Max lag", "Simulate mana" };

    public Simulation(EnhSimGUIFrame esgFrame) {
	fieldNames.put("Miss", DataPoint.miss);
	fieldNames.put("Dodge", DataPoint.dodge);
	fieldNames.put("Glancing", DataPoint.glancing);
	fieldNames.put("Armor", DataPoint.armor);
	fieldNames.put("Spell miss", DataPoint.spell_miss);
	fieldNames.put("Nature resist", DataPoint.nature_resistance);
	fieldNames.put("Fire resist", DataPoint.fire_resistance);
	fieldNames.put("Frost resist", DataPoint.frost_resistance);
	fieldNames.put("Arcane resist", DataPoint.arcane_resistance);
	fieldNames.put("Shadow resist", DataPoint.shadow_resistance);

	fieldNames.put("Sim time (hours)", DataPoint.simulation_time);
	fieldNames.put("Combat log (minutes)", DataPoint.simulation_time_combatlog);
	fieldNames.put("Combat length (minutes)", DataPoint.combat_length);
	fieldNames.put("Report count", DataPoint.report_count);
	fieldNames.put("Threads", DataPoint.threads);
	fieldNames.put("Min lag", DataPoint.min_lag);
	fieldNames.put("Max lag", DataPoint.max_lag);
	fieldNames.put("Simulate mana", DataPoint.simulate_mana);

	setupFrame(esgFrame);
    }

    private void setupFrame( EnhSimGUIFrame esgFrame ) {
	GroupLayout gl = new GroupLayout(this);

	JPanel boss = makeTextFieldArray(esgFrame, bossStats);
	boss.setBorder(BorderFactory.createTitledBorder("Boss stats"));

	JPanel simulation = makeTextFieldArray(esgFrame, simulationStats);
	simulation.setBorder(BorderFactory.createTitledBorder("Simulation stats"));

	SequentialGroup hGroup = gl.createSequentialGroup();
	SequentialGroup vGroup = gl.createSequentialGroup();

	hGroup.addGroup(gl.createParallelGroup().addComponent(boss));
	hGroup.addGroup(gl.createParallelGroup().addComponent(simulation));

	vGroup.addGroup(gl.createBaselineGroup(false, true).addComponent(boss).addComponent(simulation));

	gl.setHorizontalGroup(hGroup);
	gl.setVerticalGroup(vGroup);

	setLayout(gl);
    }

}
